﻿@{
	Layout = "~/Views/CmsAdmin/_LayoutMain.cshtml";

	ViewBag.Title = "Modules";

	var settings = new ModuleInfo(this.ViewContext);

}

@section scripts {

	@RenderSection("scripts", required: false)

}

<table style="width: 96%">
	<tr>
		<td style="width: 275px;">
			<div style="width: 250px; padding-right: 25px;">
				<div id="module-accordion">
					@foreach (var mod in settings.Modules) {
						settings.EvalModule(mod);

						<h3>
							<a href="#">
								@mod.PluginName
							</a>
						</h3>
						<div>
							<input type="hidden" name="hdnID" id="hdnID" value="@mod.AreaKey" />
							@foreach (var plug in mod.PluginMenus.OrderBy(x => x.SortOrder).Where(x => x.IsVisible)) {
								settings.EvalPlug(plug);

								<div class="moduleLink">
									<a class="@settings.SelectedCssClass" href="@String.Format("/{0}/{1}/{2}", plug.AreaKey, plug.Controller, plug.Action)">
										@plug.Caption
									</a>
								</div>
							}
						</div>
							settings.OpenTab++;
					}
				</div>
			</div>
		</td>

		<td>
			@{
				string pluginCaption = settings.GetPluginCaption();
			}

			<h2>@pluginCaption</h2>

			<script type="text/javascript">

				$(document).ready(function () {
					moduleLoader();
				});

				$(document).ajaxComplete(function (event, xhr, settings) {
					moduleLoader();
				});

				setTimeout("moduleLoader();", 250);

				function moduleLoader() {
					modulePageLoad();
				}

				function modulePageLoad() {
					$("#module-accordion").accordion({
						heightStyle: "content",
						active: parseInt('@settings.SelectedTab')
					});

					$('#tabExtensions').attr('class', "current sub");
				}
			</script>

			@RenderBody()
		</td>
	</tr>
</table>

@section footer {

	@RenderSection("footer", required: false)

}